package mi.payment.utils;

import mi.payment.db.dao.PayDetail;

/**
 * 订单判断工具类
 *
 * @author Created by yiuhet on 2017/9/6.
 */

public class OrderJudgmentUtil {

    // 二维码交易判为未知状态的应答码列表
    private static final String[] ORDER_UNKNOWN_CODE_LIST = {"NE", "30", "68", "96", "98", "E4", "A7", "AA", "AW"};

    /**
     * 判断二维码订单是否为未知状态
     */
    public static boolean isQRUnknownOrder(PayDetail payDetail) {
        if (payDetail == null) return true;
        String answerCode = payDetail.getTradeAnswerCode();
        for (String code : ORDER_UNKNOWN_CODE_LIST) {
            if (code.equals(answerCode)) {
                return true;
            }
        }
        return payDetail.getQRCodeTransState() == 2;
    }

}
